﻿using FFMpegConv;
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileConvert
{

    public class FLVConvert : IConvert
    {
        public FLVConvert(string fromFile, string toFile)
        {
            _formFile = fromFile;
            _toFile = toFile;
            _ext = System.IO.Path.GetExtension(fromFile);
        }
        private string _formFile = "";
        private string _toFile = "";
        string _ext = "";
        public string SupportFormat
        {
            get
            {
                return ".avi;.wmv;.mp4;";
            }
        }

        public bool Convert()
        {
            bool result = false;

            string cmd = "";
            switch (_ext)
            {
                case ".avi":
                case ".wmv":
                case ".mp4":
                    cmd = string.Format(BlueCmd.GetCmd(BlueOptions.flv), _formFile, _toFile);
                    break;
            }
            if (!string.IsNullOrEmpty(cmd))
            {
                if (cmd == "1")
                {
                    result = true;
                }
                else
                {
                    string command = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tools", "ffmpeg.exe");
                    result = VideoConvert.Convert(command, cmd);
                }
            }
            return result;
        }
    }
}
